﻿/* DotNetHoldem 
 * .Net Solution that allows to use OpenHoldem with .Net logic
 * Author: Óscar Andreu
 * oesido at gmail dot com
 * Licensed under GPLv3 - 2012
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using DotNetBotLogic.Classes.Log;

namespace DotNetBotLogic.Classes
{

    internal class OH_Wrapper
    {
        #region OH function delegates

        private delegate void SendChatMessageFomDllDelegate(string msg);
        SendChatMessageFomDllDelegate sendChatMessageFomDll;

        private delegate void GetPrw1326FromDllDelegate();
        GetPrw1326FromDllDelegate getPrw1326FromDll;

        private delegate void GetPhl1kFromDllDelegate();
        GetPhl1kFromDllDelegate getPhl1kFromDll;

        private delegate double GetSymbolFromDllDelegate(int chair, string symbol);
        GetSymbolFromDllDelegate getSymbolFromDll;

        private delegate holdem_state GetHoldemStateDelegate();
        GetHoldemStateDelegate getHoldemState;

        private delegate string GetPlayerNameDelegate(int chair);
        GetPlayerNameDelegate getPlayerName;

        #endregion

        public OH_Wrapper(IntPtr getSymbolFromDll, IntPtr getPlayerName)
        {
            this.getSymbolFromDll = (GetSymbolFromDllDelegate)Marshal.GetDelegateForFunctionPointer(getSymbolFromDll, typeof(GetSymbolFromDllDelegate));
            this.getPlayerName = (GetPlayerNameDelegate)Marshal.GetDelegateForFunctionPointer(getPlayerName, typeof(GetPlayerNameDelegate));
        }

        internal holdem_state Getholdemstate()
        {
            return this.getHoldemState();
        }

        internal string GetPlayerName(int chair)
        {
            return this.getPlayerName(chair);
        }

        internal double GetSym(int chair, string name)
        {
            return this.getSymbolFromDll(chair, name);
        }

        internal double GetSym(string name)
        {
            int mychair = (int)this.getSymbolFromDll(0, "userchair");

            return this.getSymbolFromDll(mychair, name);
        }
    }
}
